<template>
	<gui-page :customHeader="true" :headerClass="['gui-bg-white']" ref="guiPage" :fullPage="true">
		<!-- 自定义头部导航 -->
		<template v-slot:gHeader>
			<view style="height:44px;" class="gui-flex gui-nowrap gui-rows gui-align-items-center">
				<!-- 使用组件实现返回按钮及返回首页按钮 -->
				<gui-header-leading :home="false"></gui-header-leading>
				<!-- 导航文本此处也可以是其他自定义内容 -->
				<view style="width:44rpx;"></view>
				<text class="gui-flex1 gui-text-center gui-ellipsis">详情</text>
				<!-- 此处加一个右侧展位元素与左侧同宽，实现标题居中 -->
				<!-- 实际宽度请根据自己情况设置 -->
				<view style="width:120rpx;"></view>
				<!-- 如果右侧有其他内容可以利用条件编译和定位来实现-->
			</view>
		</template>

		<template v-slot:gBody>
			<view class="gui-relative">
				<view class="hulu-main">
					<view class="gui-padding">
						<text class="gui-text gui-color-black">流程环节</text>
					</view>
					<view class="" v-if="repair.ticket">
						<view class="gui-padding-x gui-bg-white" v-if="repair.ticket.processes&&repair.ticket.processes.length>0">
							<up-steps :current="currentStep" direction="column">
								<up-steps-item :title="t.comment" :desc="t.created_at" v-for="(t,index) in repair.ticket.processes"
									:key="index">
								</up-steps-item>
							</up-steps>
						</view>
					</view>
					
					<view class="gui-padding">
						<text class="gui-text gui-color-black">维修信息</text>
					</view>
					<view class="gui-padding-x gui-bg-white">
						<view class="bill-content">
							<view class="" style="height:24rpx;">

							</view>
							<view class="bill-content-main">
								<text class="hulu-font-4 hulu-text-color7 gui-color-black">图片</text>
								<view class="content-imgs gui-margin">
									<view class="content-img" v-if="repair" v-for="(r,i) in repair.images"
										:key="i">
										<image @tap="onTapImage(i)" :src="r" mode="aspectFill"
											style="width:168rpx;height:168rpx;"></image>
									</view>
								</view>
								<text class="hulu-font-4 hulu-text-color7 gui-color-black">摘要</text>
								<view class="content-feather hulu-font-5 gui-margin">
									<view class="hulu-text-color4" v-if="repair">
										<view>
											{{repair.user_name}}
										</view>
										<view class="">
											{{repair.phone}}
										</view>
										<view class="">
											{{repair.license}}
										</view>
										<view class="">
											{{repair.description}}
										</view>
										<view class="">
											{{repair.created_at}}
										</view>
										<view class="gui-flex">
											{{repair.address}}
											<u-icon v-if="repair.address" name="map-fill" color="#2979ff" size="20"
												@tap="navTo(repair)"></u-icon>
										</view>
									</view>
								</view>
								<text class="hulu-font-4 hulu-text-color7 gui-color-black">项目</text>
								<view class="content-feather hulu-font-5 gui-margin">
									<view v-if="repair && repair.ticket" v-for="(s,index) in repair.ticket.services" :key="index">{{s.name}}x️1
									</view>
								</view>
								<text class="hulu-font-4 hulu-text-color7 gui-color-black">维修工</text>
								<view class="content-price">
									<view class="gui-flex gui-justify-content-start gui-margin" v-if="repair.ticket">
										<text class="hulu-text-color3"  v-for="(u,idx) in repair.ticket.users"
											:key="idx">
											{{u.name}}
										</text>
									</view>
								</view>
							</view>
							<view class="" style="height:24rpx;">

							</view>
						</view>
					</view>

					
				</view>
				<view class="" style="height:68rpx;">

				</view>
			</view>
		</template>
	</gui-page>
</template>
<script>
	import useRepair from "@/api/repair"
	import graceJS from '@/Grace6/js/grace.js';
	const {
		showRepair
	} = useRepair()
	export default {
		data() {
			return {
				currentStep: 0,
				repair: {},
				id: null
			}
		},
		created() {},
		mounted() {},
		onLoad(option) {
			// uni.getSystemInfo({
			// 	success: (res) => {
			// 		console.log('屏幕高度：' + res.windowHeight);
			// 		// 在这里可以使用 res.windowHeight 做其他操作
			// 		// 64rpx
			// 		// 已知的固定高度
			// 		const topNavBarHeight = 44; // 顶部导航栏高度，单位 px
			// 		const switchNavHeight = 64; // 切换导航高度，单位 px
			// 		const bottomNavBarHeight = 50; // 底部导航高度，单位 px
			// 		// 计算调整后的高度
			// 		const adjustedHeightPx = res.windowHeight - topNavBarHeight - switchNavHeight -
			// 			bottomNavBarHeight;
			// 		this.mainHeight = adjustedHeightPx * 2;

			// 		console.log('调整后的高度：' + this.mainHeight + 'px');
			// 	},
			// 	fail: function(err) {
			// 		console.error('获取系统信息失败：', err);
			// 	}
			// });
			this.id = +(option.id)
			this.getRepair()
		},
		methods: {
			async getRepair() {
				const {
					data
				} = await showRepair(this.id)
				this.repair = data
				this.currentStep = data.processes?data.processes.length:0
			},
			onTapImage(i) {
				uni.previewImage({
					current: i + 1,
					urls: this.repair.images
				})
			},
			navTo(repair) {
				uni.openLocation({
					latitude: repair.coordinates.coordinates[1],
					longitude: repair.coordinates.coordinates[0],
				})
			},

		},
	}
</script>
<style lang="scss">
	.hulu-main {
		padding: 0 24rpx;
		box-sizing: border-box;
	}

	.bill-content {
		.bill-content-main {
			.content-imgs {
				display: flex;
				justify-content: flex-start;

				.content-img {
					-webkit-box-shadow: 0px -2px 12px 0px rgba(0, 0, 0, 0.2);
					-moz-box-shadow: 0px -2px 12px 0px rgba(0, 0, 0, 0.2);
					box-shadow: 0px -2px 12px 0px rgba(0, 0, 0, 0.2);
				}
			}


			.content-feather {
				display: flex;
				flex-direction: column;
				justify-content: flex-start;
				align-items: flex-start;
			}

			.content-price {
				font-size: 22rpx;
			}
		}
	}

	.gui-td {
		width: 100rpx;
		flex: 1;
		overflow: hidden;
		padding: 10rpx 10rpx;
		display: flexbox;
	}

	.gui-primary-text {
		line-height: 60rpx !important;
		font-size: 24rpx;
	}
</style>